<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- 上述meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <!-- Bootstrap CSS -->
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    <title>抖查查测试平台</title>
</head>
<body>
<div class="row " style="margin-top: 20px">
    <div class="col-md-20  container" >
        <form class="form-inline">
            <div class="form-group" style="margin-left: -20px">
                &nbsp<label for="entry_name">项目：</label>
                <input name="entry_name" type="text" class="form-control entry_name" id="entry_name"
                       placeholder="项目名称">
            </div>
            <div class="form-group">
                &nbsp<label for="Iterative_version">迭代：</label>
                <input name="Iterative_version" type="text" class="form-control Iterative_version"
                       id="Iterative_version" placeholder="迭代版本">
            </div>
            <div class="form-group">
                &nbsp<label for="modular">模块：</label>
                <input name="modular" type="text" class="form-control modular" id="modular" placeholder="模块">
            </div>
            <div class="form-group">
                &nbsp<label for="case_name">case：</label>
                <input name="case_name" type="text" class="form-control case_name" id="case_name" placeholder="case">
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary float-right"
                        onclick="searchcase_onclick()">搜索
                </button>
            </div>
        </form>
    </div>
    <div class="col-md-1">
        <a class="btn btn-outline-primary" href="{% url 'test_interface_automation_content' %}" rel="external nofollow">新建</a>
        <a class="btn btn-outline-primary" href="{% url 'index' %}">返回</a>
    </div>

    <div style="margin-right: 60px">
        <input style="width: 88px;height: 38px; border: 1px solid #1E90FF;border-radius:4px;" type="text" id="list_id"
               placeholder="删除的ID">
        <button style="width: 58px;height: 38px; border: 1px solid #1E90FF; border-radius:4px; color: #1E90FF;background-color: #ffffff"
                onclick="delete_interface_index()">删除
        </button>
    </div>
</div>

<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto">
    {{ TestInterfaceList_search }}
    <table data-table class="table table-hover">
        {% if TestInterfaceList_search %}
            <thead>
            <tr bgcolor="#d1ecf1">
                <th>id</th>
                <th>项目名称</th>
                <th>迭代版本</th>
                <th>模块</th>
                <th>case</th>
                <th>编辑</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>{{ TestInterfaceList_search.id }}</td>
                <td>{{ TestInterfaceList_search.entry_name }}</td>
                <td>{{ TestInterfaceList_search.Iterative_version }}</td>
                <td>{{ TestInterfaceList_search.modular }}</td>
                <td>{{ TestInterfaceList_search.case_name }}</td>
                <td>
                    <button style="width: 58px;height: 38px; border: 1px solid #1E90FF; border-radius:4px; color: #1E90FF;background-color: #ffffff;"
                            onclick="View_details({{ TestInterfaceList_search.id }})">查看
                    </button>
                </td>
            </tr>
            </tbody>
        {% else %}
            {% if TestInterfaceList %}
                <thead>
                <tr bgcolor="#d1ecf1">
                    <th>ID</th>
                    <th>项目名称</th>
                    <th>迭代版本</th>
                    <th>模块</th>
                    <th>case</th>
                    <th>编辑</th>
                </tr>
                </thead>
                <tbody>
                {% for i in TestInterfaceList %}
                    <tr>
                        <td>{{ i.id }}</td>
                        <td>{{ i.entry_name }}</td>
                        <td>{{ i.Iterative_version }}</td>
                        <td>{{ i.modular }}</td>
                        <td>{{ i.case_name }}</td>
                        <td>
                            <button style="width: 58px;height: 38px; border: 1px solid #1E90FF; border-radius:4px; color: #1E90FF;background-color: #ffffff;"
                                    onclick="View_details({{ i.id }})">查看
                            </button>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            {% else %}
                <tr>
                    <td class="subject" colspan="7">
                        <h2>没有数据我怎么给你展示，完蛋去吧！！！ 给你个 <a href="{% url 'test_interface_automation_content' %}"
                                                       rel="external nofollow">按钮</a> 赶紧去添加数据，添加完成后我给你展示 Let go！</h2>
                    </td>
                </tr>
            {% endif %}
        {% endif %}

    </table>
</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.15.0/umd/popper.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>

    function searchcase_onclick() {
        var entry_name = document.getElementById("entry_name")
        var Iterative_version = document.getElementById("Iterative_version")
        var modular = document.getElementById("modular")
        var case_name = document.getElementById("case_name")
        $.ajax(
            {
                type: "GET",
                url: "http://0.0.0.0:8089/polls/Test_interface_automation",
                data: {
                    entry_name: entry_name.value,
                    Iterative_version: Iterative_version.value,
                    modular: modular.value,
                    case_name: case_name.value
                },
                success: function (data) {
                    alert(data)
                    window.location.reload()
                }
            })
    }

    function delete_interface_index() {
        var List_id = document.getElementById("list_id");
        $.ajax(
            {
                type: "GET",
                url: "http://127.0.0.1:8089/polls/delete_interface",
                data: {
                    list_id: List_id.value
                },
                success: function (data) {
                    alert(data)
                    window.location.reload()
                }

            })
    }

    function View_details(id) {
        window.location.href = 'http://127.0.0.1:8089/polls/test_interface_automation_content?id=' + id
    }

</script>
</body>
</html>
